<template>
  <div class="page">
    <h2>
      <a @click="back" class="btnBack">返回</a>
      订单详情
    </h2>
    <div class="payOrderBox">
      <div class="base">
        <img :src="detail.p_cover" alt=""/>
        <div class="title">{{detail.p_title}}</div>
      </div>
      <ul>
        <li>订单号：{{detail.id}}</li>
        <li>份　　数：{{detail.o_copies}}</li>
        <li>订单价格：{{detail.o_price}}</li>
      </ul>
      <ul>
        <li>支付状态：未支付</li>
        <li>支付方式：xxx</li>
        <li>支付金额：{{detail.o_price}}</li>
        <li>支付时间：{{detail.create_date}}</li>
      </ul>
      <div class="ctrl">
        <router-link :to="'/product/'+detail.p_id" class="a1" >再来一份</router-link>
        <a onClick={this.onShare.bind(this)} >分享</a>
      </div>
    </div>
  </div>
</template>

<script>
import $ from 'jquery'
import router from '../router'
import Api from '../api'

export default {
  props: {
    message: String
  },
  name: 'HelloWorld-',
  data () {
    return {
      rootApi: 'http://localhost:4000/',
      msg: 'Welcome to Your Vue.js App-1qqqqq',
      detail:{}
    }
  },
  methods: {
    back(){
      router.go(-1);
    },
    goDetail(id){
      router.push('/product/'+id);
    },
    getDetailData(id) {
      Api.getOrderDetail({
        data: {
          id: id
        },
        success: (d) => {
          this.detail = d.data;
        }
      });
    },
  },
  mounted: function () {
    let id = router.history.current.params.id;
    this.getDetailData(id);
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" rel="stylesheet/less">
  .payBox-style1{ margin: 0 0 10px 0 ; box-shadow:0px 1px 0px 0 rgba(0, 0, 0, 0.3);  background: #f7f7f7;  }
  .payBox-style1{ margin: 0 0 10px 0 ; box-shadow:0px 1px 0px 0 rgba(0, 0, 0, 0.3);  background: #f7f7f7;  }
  .payBox-title{ font-weight: 600; font-size:14px;padding: 0 10px; line-height: 30px;}
  .payOrderBox{
    .payBox-style1;text-align: left;
    h3{.payBox-title; }
    .base{
      line-height: 30px;
      img{width: 100px; float: left; margin: 10px;}
    }
    ul{
      clear: both; margin: 0 0 10px 0; border-bottom: 1px dashed #ccc;
      li{ line-height: 22px;padding:0 10px; }
    }
    .ctrl{
      display: flex; flex-direction: row; justify-content: flex-end; padding: 0 0 10px 0;
      a{  background:#999; margin: 0 10px; padding: 10px; }
      .a1{ background:#d0b161; }
    }
  }
  .btnBack{float: left; font-size: 14px; line-height:30px;}
</style>
